﻿USE [SampleInvoice]
GO
/****** Object:  Table [dbo].[InvoiceLine]    Script Date: 06/06/2009 00:26:02 ******/
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [FK_InvoiceLine_Invoice]
GO
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [FK_InvoiceLine_Product]
GO
DROP TABLE [dbo].[InvoiceLine]
GO
/****** Object:  Table [dbo].[Product]    Script Date: 06/06/2009 00:26:02 ******/
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [FK_Product_CatalogFolder]
GO
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [FK_Product_Supplier]
GO
DROP TABLE [dbo].[Product]
GO
/****** Object:  Table [dbo].[Invoice]    Script Date: 06/06/2009 00:26:02 ******/
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [FK_Invoice_Customer]
GO
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [FK_Invoice_InvoiceStatus]
GO
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_StateCode]
GO
DROP TABLE [dbo].[Invoice]
GO
/****** Object:  Table [dbo].[Customer]    Script Date: 06/06/2009 00:26:01 ******/
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [FK_Customer_Contact]
GO
DROP TABLE [dbo].[Customer]
GO
/****** Object:  Table [dbo].[Supplier]    Script Date: 06/06/2009 00:26:01 ******/
ALTER TABLE [dbo].[Supplier] DROP CONSTRAINT [FK_Supplier_Contact]
GO
DROP TABLE [dbo].[Supplier]
GO
/****** Object:  Table [dbo].[InvoiceStatus]    Script Date: 06/06/2009 00:26:01 ******/
DROP TABLE [dbo].[InvoiceStatus]
GO
/****** Object:  Table [dbo].[CatalogFolder]    Script Date: 06/06/2009 00:26:01 ******/
ALTER TABLE [dbo].[CatalogFolder] DROP CONSTRAINT [FK_CatalogFolder_CatalogFolder]
GO
DROP TABLE [dbo].[CatalogFolder]
GO
/****** Object:  Table [dbo].[Contact]    Script Date: 06/06/2009 00:26:01 ******/
DROP TABLE [dbo].[Contact]
GO
/****** Object:  Table [dbo].[Contact]    Script Date: 06/06/2009 00:26:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Contact](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](50) NOT NULL,
	[Address] [ntext] NULL,
	[Email] [varchar](250) NULL,
	[LastChanged] [date] NULL,
 CONSTRAINT [PK_Contact] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET IDENTITY_INSERT [dbo].[Contact] ON
INSERT [dbo].[Contact] ([ID], [Name], [Address], [Email], [LastChanged]) VALUES (1, N'Acme Factory Manchester', N'Manchester', N'manchester.factory@acme.co.uk', NULL)
INSERT [dbo].[Contact] ([ID], [Name], [Address], [Email], [LastChanged]) VALUES (2, N'Acme Factory Brighton', N'Brighton', N'brighton.factory@acme.co.uk', NULL)
INSERT [dbo].[Contact] ([ID], [Name], [Address], [Email], [LastChanged]) VALUES (3, N'ACME Dublin', NULL, NULL, NULL)
INSERT [dbo].[Contact] ([ID], [Name], [Address], [Email], [LastChanged]) VALUES (4, N'Twain & Sons', N'23000 Dallas', NULL, NULL)
INSERT [dbo].[Contact] ([ID], [Name], [Address], [Email], [LastChanged]) VALUES (5, N'Smith Corp.', N'10000 Washington', NULL, NULL)
INSERT [dbo].[Contact] ([ID], [Name], [Address], [Email], [LastChanged]) VALUES (6, N'Triple T', N'89200 Boston', NULL, NULL)
SET IDENTITY_INSERT [dbo].[Contact] OFF
/****** Object:  Table [dbo].[CatalogFolder]    Script Date: 06/06/2009 00:26:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[CatalogFolder](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[ParentID] [bigint] NULL,
	[Name] [varchar](256) NOT NULL,
	[LastChanged] [date] NULL,
 CONSTRAINT [PK_CatalogFolder] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [UK_CatalogFolder_ParentID_Name] UNIQUE NONCLUSTERED 
(
	[ParentID] ASC,
	[Name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET IDENTITY_INSERT [dbo].[CatalogFolder] ON
INSERT [dbo].[CatalogFolder] ([ID], [ParentID], [Name], [LastChanged]) VALUES (1, NULL, N'My Catalog', NULL)
INSERT [dbo].[CatalogFolder] ([ID], [ParentID], [Name], [LastChanged]) VALUES (2, 1, N'Alimentary', NULL)
INSERT [dbo].[CatalogFolder] ([ID], [ParentID], [Name], [LastChanged]) VALUES (3, 1, N'Cartoons', NULL)
INSERT [dbo].[CatalogFolder] ([ID], [ParentID], [Name], [LastChanged]) VALUES (4, 1, N'Goodies', NULL)
INSERT [dbo].[CatalogFolder] ([ID], [ParentID], [Name], [LastChanged]) VALUES (5, 1, N'Misc', NULL)
INSERT [dbo].[CatalogFolder] ([ID], [ParentID], [Name], [LastChanged]) VALUES (6, 2, N'Beferages', NULL)
INSERT [dbo].[CatalogFolder] ([ID], [ParentID], [Name], [LastChanged]) VALUES (7, 2, N'Food', NULL)
INSERT [dbo].[CatalogFolder] ([ID], [ParentID], [Name], [LastChanged]) VALUES (8, 3, N'Seeds', NULL)
INSERT [dbo].[CatalogFolder] ([ID], [ParentID], [Name], [LastChanged]) VALUES (9, 3, N'DIYS Kits', NULL)
INSERT [dbo].[CatalogFolder] ([ID], [ParentID], [Name], [LastChanged]) VALUES (10, 3, N'Machines', NULL)
INSERT [dbo].[CatalogFolder] ([ID], [ParentID], [Name], [LastChanged]) VALUES (11, 3, N'Other', NULL)
INSERT [dbo].[CatalogFolder] ([ID], [ParentID], [Name], [LastChanged]) VALUES (12, 15, N'Circle A', NULL)
INSERT [dbo].[CatalogFolder] ([ID], [ParentID], [Name], [LastChanged]) VALUES (13, 12, N'Circle A.A', NULL)
INSERT [dbo].[CatalogFolder] ([ID], [ParentID], [Name], [LastChanged]) VALUES (14, 12, N'Circle A.B', NULL)
INSERT [dbo].[CatalogFolder] ([ID], [ParentID], [Name], [LastChanged]) VALUES (15, 13, N'Circle A.A.A', NULL)
SET IDENTITY_INSERT [dbo].[CatalogFolder] OFF
/****** Object:  Table [dbo].[InvoiceStatus]    Script Date: 06/06/2009 00:26:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[InvoiceStatus](
	[Code] [varchar](16) NOT NULL,
	[Label] [varchar](50) NOT NULL,
 CONSTRAINT [PK_InvoiceStatus] PRIMARY KEY CLUSTERED 
(
	[Code] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
INSERT [dbo].[InvoiceStatus] ([Code], [Label]) VALUES (N'CLOSED', N'Closed')
INSERT [dbo].[InvoiceStatus] ([Code], [Label]) VALUES (N'CONFIRMED', N'Confirmed')
INSERT [dbo].[InvoiceStatus] ([Code], [Label]) VALUES (N'DELIVERED', N'Delivered')
INSERT [dbo].[InvoiceStatus] ([Code], [Label]) VALUES (N'NEW', N'New')
INSERT [dbo].[InvoiceStatus] ([Code], [Label]) VALUES (N'OPEN', N'Open')
INSERT [dbo].[InvoiceStatus] ([Code], [Label]) VALUES (N'PAID', N'Paid')
/****** Object:  Table [dbo].[Supplier]    Script Date: 06/06/2009 00:26:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Supplier](
	[ContactID] [bigint] NOT NULL,
 CONSTRAINT [PK_Supplier] PRIMARY KEY CLUSTERED 
(
	[ContactID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
INSERT [dbo].[Supplier] ([ContactID]) VALUES (1)
INSERT [dbo].[Supplier] ([ContactID]) VALUES (2)
INSERT [dbo].[Supplier] ([ContactID]) VALUES (3)
/****** Object:  Table [dbo].[Customer]    Script Date: 06/06/2009 00:26:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Customer](
	[ContactID] [bigint] NOT NULL,
	[Level] [int] NULL,
 CONSTRAINT [PK_Customer] PRIMARY KEY CLUSTERED 
(
	[ContactID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
INSERT [dbo].[Customer] ([ContactID], [Level]) VALUES (4, 100)
INSERT [dbo].[Customer] ([ContactID], [Level]) VALUES (5, NULL)
INSERT [dbo].[Customer] ([ContactID], [Level]) VALUES (6, NULL)
/****** Object:  Table [dbo].[Invoice]    Script Date: 06/06/2009 00:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Invoice](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[InvoiceDate] [date] NOT NULL,
	[CustomerID] [bigint] NOT NULL,
	[Comments] [ntext] NULL,
	[StateCode] [varchar](16) NOT NULL CONSTRAINT [DF_Invoice_StateCode]  DEFAULT ('NEW'),
	[LastChanged] [date] NULL,
 CONSTRAINT [PK_Invoice] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE NONCLUSTERED INDEX [IX_Invoice_InvoiceDate] ON [dbo].[Invoice] 
(
	[InvoiceDate] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
SET IDENTITY_INSERT [dbo].[Invoice] ON
INSERT [dbo].[Invoice] ([ID], [InvoiceDate], [CustomerID], [Comments], [StateCode], [LastChanged]) VALUES (3, CAST(0xE3300B00 AS Date), 4, NULL, N'NEW', NULL)
INSERT [dbo].[Invoice] ([ID], [InvoiceDate], [CustomerID], [Comments], [StateCode], [LastChanged]) VALUES (4, CAST(0xE3300B00 AS Date), 5, NULL, N'NEW', NULL)
INSERT [dbo].[Invoice] ([ID], [InvoiceDate], [CustomerID], [Comments], [StateCode], [LastChanged]) VALUES (5, CAST(0xE3300B00 AS Date), 5, NULL, N'NEW', NULL)
INSERT [dbo].[Invoice] ([ID], [InvoiceDate], [CustomerID], [Comments], [StateCode], [LastChanged]) VALUES (6, CAST(0xE3300B00 AS Date), 5, NULL, N'NEW', NULL)
SET IDENTITY_INSERT [dbo].[Invoice] OFF
/****** Object:  Table [dbo].[Product]    Script Date: 06/06/2009 00:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Product](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[Label] [varchar](80) NOT NULL,
	[Description] [ntext] NULL,
	[SalePrice] [money] NULL,
	[LastChanged] [date] NULL,
	[SupplierID] [bigint] NULL,
	[CatalogFolderID] [bigint] NULL,
 CONSTRAINT [PK_Product] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE UNIQUE NONCLUSTERED INDEX [UK_Product] ON [dbo].[Product] 
(
	[Label] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
SET IDENTITY_INSERT [dbo].[Product] ON
INSERT [dbo].[Product] ([ID], [Label], [Description], [SalePrice], [LastChanged], [SupplierID], [CatalogFolderID]) VALUES (1, N'ACME Atom Re-Arranger', NULL, 785.0000, NULL, 1, 10)
INSERT [dbo].[Product] ([ID], [Label], [Description], [SalePrice], [LastChanged], [SupplierID], [CatalogFolderID]) VALUES (2, N'ACME Do-It-Yourself Tornado Kit', N'Easily create your own tornadoes, anywhere, with the ACME Do It Yourself Tornado kit', 440.0000, NULL, 1, 9)
INSERT [dbo].[Product] ([ID], [Label], [Description], [SalePrice], [LastChanged], [SupplierID], [CatalogFolderID]) VALUES (3, N'ACME Earthquake Pills', N'ACME Earthquake Pills are guaranteed to create huge tremors anywhere (except when used on road runners)', 12.9000, NULL, 2, 11)
INSERT [dbo].[Product] ([ID], [Label], [Description], [SalePrice], [LastChanged], [SupplierID], [CatalogFolderID]) VALUES (4, N'ACME Iron Bird Seed - 1 pound', N'ACME Iron Bird Seed, available in sizes up to one pound, is fortified with more ferrous sulfate than any other brand of bird seed', 4.9900, NULL, 2, 8)
INSERT [dbo].[Product] ([ID], [Label], [Description], [SalePrice], [LastChanged], [SupplierID], [CatalogFolderID]) VALUES (5, N'ACME Invisible Paint', NULL, 27.5000, NULL, NULL, 11)
INSERT [dbo].[Product] ([ID], [Label], [Description], [SalePrice], [LastChanged], [SupplierID], [CatalogFolderID]) VALUES (6, N'ACME Smokescreen Bomb', NULL, NULL, NULL, 1, 11)
INSERT [dbo].[Product] ([ID], [Label], [Description], [SalePrice], [LastChanged], [SupplierID], [CatalogFolderID]) VALUES (7, N'ACME Adding Machine', N'ACME Adding Machines are so easy to use that even dogs can calculate why mice hate cheese and why cats want a dog to massacre them', 250.9500, CAST(0xAD300B00 AS Date), 1, 10)
INSERT [dbo].[Product] ([ID], [Label], [Description], [SalePrice], [LastChanged], [SupplierID], [CatalogFolderID]) VALUES (8, N'ACME Artificial Rock', N'Have hours of amusement pretending to be a rock with the ACME Artificial Rock', 45.5000, CAST(0xB8300B00 AS Date), 1, 11)
INSERT [dbo].[Product] ([ID], [Label], [Description], [SalePrice], [LastChanged], [SupplierID], [CatalogFolderID]) VALUES (9, N'ACME Birdseed  1 pound', N'ACME Birdseed providing lots of opportunites to keep your favorite flying friends happy', 3.6000, NULL, 2, 8)
INSERT [dbo].[Product] ([ID], [Label], [Description], [SalePrice], [LastChanged], [SupplierID], [CatalogFolderID]) VALUES (10, N'ACME Boomerang', NULL, 9.9000, CAST(0x262F0B00 AS Date), 1, 11)
INSERT [dbo].[Product] ([ID], [Label], [Description], [SalePrice], [LastChanged], [SupplierID], [CatalogFolderID]) VALUES (12, N'ACME Power Dust', N'Power Dust cleans the house in a wink', 99.9500, NULL, 3, 11)
SET IDENTITY_INSERT [dbo].[Product] OFF
/****** Object:  Table [dbo].[InvoiceLine]    Script Date: 06/06/2009 00:26:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[InvoiceLine](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[InvoiceID] [bigint] NOT NULL,
	[ProductID] [bigint] NOT NULL,
	[UnitPrice] [money] NULL,
	[Quantity] [float] NULL,
	[Comments] [ntext] NULL,
	[LastChanged] [date] NULL,
 CONSTRAINT [PK_InvoiceLine] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET IDENTITY_INSERT [dbo].[InvoiceLine] ON
INSERT [dbo].[InvoiceLine] ([ID], [InvoiceID], [ProductID], [UnitPrice], [Quantity], [Comments], [LastChanged]) VALUES (4, 3, 4, 4.9900, 1, NULL, NULL)
INSERT [dbo].[InvoiceLine] ([ID], [InvoiceID], [ProductID], [UnitPrice], [Quantity], [Comments], [LastChanged]) VALUES (5, 3, 6, NULL, 2, NULL, NULL)
INSERT [dbo].[InvoiceLine] ([ID], [InvoiceID], [ProductID], [UnitPrice], [Quantity], [Comments], [LastChanged]) VALUES (6, 3, 7, 250.9500, 3, NULL, NULL)
INSERT [dbo].[InvoiceLine] ([ID], [InvoiceID], [ProductID], [UnitPrice], [Quantity], [Comments], [LastChanged]) VALUES (7, 4, 1, 785.0000, 5, NULL, NULL)
INSERT [dbo].[InvoiceLine] ([ID], [InvoiceID], [ProductID], [UnitPrice], [Quantity], [Comments], [LastChanged]) VALUES (8, 5, 2, 440.0000, 3, NULL, NULL)
INSERT [dbo].[InvoiceLine] ([ID], [InvoiceID], [ProductID], [UnitPrice], [Quantity], [Comments], [LastChanged]) VALUES (9, 5, 4, 4.9900, 2, NULL, NULL)
INSERT [dbo].[InvoiceLine] ([ID], [InvoiceID], [ProductID], [UnitPrice], [Quantity], [Comments], [LastChanged]) VALUES (10, 6, 3, 12.9000, 3, NULL, NULL)
INSERT [dbo].[InvoiceLine] ([ID], [InvoiceID], [ProductID], [UnitPrice], [Quantity], [Comments], [LastChanged]) VALUES (11, 6, 5, 27.5000, 2, NULL, NULL)
INSERT [dbo].[InvoiceLine] ([ID], [InvoiceID], [ProductID], [UnitPrice], [Quantity], [Comments], [LastChanged]) VALUES (12, 6, 6, NULL, 8, NULL, NULL)
SET IDENTITY_INSERT [dbo].[InvoiceLine] OFF
/****** Object:  ForeignKey [FK_CatalogFolder_CatalogFolder]    Script Date: 06/06/2009 00:26:01 ******/
ALTER TABLE [dbo].[CatalogFolder]  WITH CHECK ADD  CONSTRAINT [FK_CatalogFolder_CatalogFolder] FOREIGN KEY([ParentID])
REFERENCES [dbo].[CatalogFolder] ([ID])
GO
ALTER TABLE [dbo].[CatalogFolder] CHECK CONSTRAINT [FK_CatalogFolder_CatalogFolder]
GO
/****** Object:  ForeignKey [FK_Supplier_Contact]    Script Date: 06/06/2009 00:26:01 ******/
ALTER TABLE [dbo].[Supplier]  WITH CHECK ADD  CONSTRAINT [FK_Supplier_Contact] FOREIGN KEY([ContactID])
REFERENCES [dbo].[Contact] ([ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[Supplier] CHECK CONSTRAINT [FK_Supplier_Contact]
GO
/****** Object:  ForeignKey [FK_Customer_Contact]    Script Date: 06/06/2009 00:26:01 ******/
ALTER TABLE [dbo].[Customer]  WITH CHECK ADD  CONSTRAINT [FK_Customer_Contact] FOREIGN KEY([ContactID])
REFERENCES [dbo].[Contact] ([ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[Customer] CHECK CONSTRAINT [FK_Customer_Contact]
GO
/****** Object:  ForeignKey [FK_Invoice_Customer]    Script Date: 06/06/2009 00:26:02 ******/
ALTER TABLE [dbo].[Invoice]  WITH CHECK ADD  CONSTRAINT [FK_Invoice_Customer] FOREIGN KEY([CustomerID])
REFERENCES [dbo].[Customer] ([ContactID])
ON UPDATE CASCADE
GO
ALTER TABLE [dbo].[Invoice] CHECK CONSTRAINT [FK_Invoice_Customer]
GO
/****** Object:  ForeignKey [FK_Invoice_InvoiceStatus]    Script Date: 06/06/2009 00:26:02 ******/
ALTER TABLE [dbo].[Invoice]  WITH CHECK ADD  CONSTRAINT [FK_Invoice_InvoiceStatus] FOREIGN KEY([StateCode])
REFERENCES [dbo].[InvoiceStatus] ([Code])
GO
ALTER TABLE [dbo].[Invoice] CHECK CONSTRAINT [FK_Invoice_InvoiceStatus]
GO
/****** Object:  ForeignKey [FK_Product_CatalogFolder]    Script Date: 06/06/2009 00:26:02 ******/
ALTER TABLE [dbo].[Product]  WITH CHECK ADD  CONSTRAINT [FK_Product_CatalogFolder] FOREIGN KEY([CatalogFolderID])
REFERENCES [dbo].[CatalogFolder] ([ID])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[Product] CHECK CONSTRAINT [FK_Product_CatalogFolder]
GO
/****** Object:  ForeignKey [FK_Product_Supplier]    Script Date: 06/06/2009 00:26:02 ******/
ALTER TABLE [dbo].[Product]  WITH CHECK ADD  CONSTRAINT [FK_Product_Supplier] FOREIGN KEY([SupplierID])
REFERENCES [dbo].[Supplier] ([ContactID])
ON UPDATE CASCADE
GO
ALTER TABLE [dbo].[Product] CHECK CONSTRAINT [FK_Product_Supplier]
GO
/****** Object:  ForeignKey [FK_InvoiceLine_Invoice]    Script Date: 06/06/2009 00:26:02 ******/
ALTER TABLE [dbo].[InvoiceLine]  WITH CHECK ADD  CONSTRAINT [FK_InvoiceLine_Invoice] FOREIGN KEY([InvoiceID])
REFERENCES [dbo].[Invoice] ([ID])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[InvoiceLine] CHECK CONSTRAINT [FK_InvoiceLine_Invoice]
GO
/****** Object:  ForeignKey [FK_InvoiceLine_Product]    Script Date: 06/06/2009 00:26:02 ******/
ALTER TABLE [dbo].[InvoiceLine]  WITH CHECK ADD  CONSTRAINT [FK_InvoiceLine_Product] FOREIGN KEY([ProductID])
REFERENCES [dbo].[Product] ([ID])
GO
ALTER TABLE [dbo].[InvoiceLine] CHECK CONSTRAINT [FK_InvoiceLine_Product]
GO
